#Replication File 2 for "Political Overconfidence Strengthens the Durability of Misperceptions"
#2021 Lucid Sample
#Use "Study2.csv"

#Libraries
require(tidyverse)
require(car)
require(ggthemes)
require(stargazer)

dat <- read.csv("Study2.csv")

#Table 2

mod1 <- lm(data=dat[dat$overconf==1,],skepticism~knowReveal+
             misinfoReveal+
             knowReveal*misinfoReveal)

stargazer(mod1,type="html",out="table2.html",
          covariate.labels=c(
            "T1: Large Majority Inoculation Message",
            "T2: Confidence Adjustment",
            "T3: Confidence Adjustment*Inoculation",
            "Constant"),
          star.cutoffs = c(0.05,0.01,0.001),
          title = "Table 2. Results of OLS Regression Model Predicting Skepticism Among the Overconfident [0:1]"
)


#Full Sample Results

mod1_full <- lm(data=dat,skepticism~knowReveal+
             misinfoReveal+
             knowReveal*misinfoReveal)

stargazer(mod1_full,type="html",out="table2_full.html",
          covariate.labels=c(
            "T1: Large Majority Inoculation Message",
            "T2: Confidence Adjustment",
            "T3: Confidence Adjustment*Inoculation",
            "Constant"),
          star.cutoffs = c(0.05,0.01,0.001),
          title = "Table A8. Results of OLS Regression Model Predicting Skepticism, Full Sample [0:1]"
)

#Manipulation Checks
mc1 <- lm(dat$knowdv_rate~dat$knowReveal)
mc2 <- lm(dat$knowdv_rate~dat$knowReveal+dat$overconf+dat$knowReveal*dat$overconf)
mc3 <- lm(dat$knowdv_usa~dat$knowReveal)
mc4 <- lm(dat$knowdv_usa~dat$knowReveal+dat$overconf+dat$knowReveal*dat$overconf)

stargazer(mc1,mc2,mc3,mc4,type="html",out="manipulation_checks.html",
          covariate.labels=c(
            "Confidence Adjustment Task Exposure",
            "Confidence Accuracy [-1:1]",
            "Task Exposure*Accuracy",
            "Constant"),
          star.cutoffs = c(0.05,0.01,0.001),
          title = "Table A6. Results of OLS Regression Models Predicting Two Manipulation Check Measures [0:1]"
)

#Robustness Checks

#Alternative Binary Specification of Overconfidence: Replication of Table 2

mod1_alt <- lm(data=dat[dat$overconf2==1,],skepticism~knowReveal+
             misinfoReveal+
             knowReveal*misinfoReveal)

stargazer(mod1_alt,type="html",out="tableA9.html",
          covariate.labels=c(
            "T1: Large Majority Inoculation Message",
            "T2: Confidence Adjustment",
            "T3: Confidence Adjustment*Inoculation",
            "Constant"),
          star.cutoffs = c(0.05,0.01,0.001),
          title = "Table A9. Results of OLS Regression Model Predicting Skepticism Among the Overconfident [0:1]"
)

#Alternative Explanation: Straightlining Not Affected by Treatment


straightlineMod <- glm(data=dat[dat$overconf==1,],straightlining~knowReveal+
                         misinfoReveal+
                         knowReveal*misinfoReveal,family=binomial(link="logit"))


stargazer(straightlineMod,type="html",out="straightlining.html",
          covariate.labels=c(
            "T1: Large Majority Inoculation Message",
            "T2: Confidence Adjustment",
            "T3: Confidence Adjustment*Inoculation",
            "Constant"),
          star.cutoffs = c(0.05,0.01,0.001),
          title = "Table A7. Results of Logistic Regression Model Predicting Post-Treatment Straightlining Among the Overconfident"
)





